class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        int array[26] = {0};
        for (auto& c: magazine) {
            array[c - 'a']++;
        }
        for (auto& c: ransomNote) {
            array[c - 'a']--;
            if (array[c - 'a'] < 0) return false;
        }
        return true;
    }
};